package cn.edu.sjtu.se.dslab.project;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "display_zone")
public class DisplayZone implements Serializable,Cloneable{
	private static final long serialVersionUID = -6397362357745939281L;
	
	private long id;
	private String name;
	private int size;
	private String entityUri;
	private Project project;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@Column(nullable = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(nullable = false)
	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	@ManyToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "project_id", nullable = false)
	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	@Column(nullable = false)
	public String getEntityUri() {
		return entityUri;
	}

	public void setEntityUri(String entityUri) {
		this.entityUri = entityUri;
	}
	
	@Override
	public Object clone() {
		DisplayZone dz = null;
		try{
			dz = (DisplayZone)super.clone();
			dz.setId(0);
			dz.setProject(null);
		}catch(CloneNotSupportedException ex){
			ex.printStackTrace();
		}
		return dz;
	}
}
